<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>sessionStorage</title>
</head>
<body>
<script>
    function saveData() {
        let p = {
            name: '小明',
            age: 11,
            sex: '男'
        }
        window.sessionStorage.setItem('person', JSON.stringify(p))
        window.sessionStorage.setItem('name', '小明')
        window.sessionStorage.setItem('age', '11')
    }
    function getData() {
        let p = JSON.parse(window.sessionStorage.getItem('person'))
        console.log(p)
        console.log(window.sessionStorage.getItem('name'))
        console.log(window.sessionStorage.getItem('age'))
    }
    function deleteData() {
        window.sessionStorage.removeItem('person')
    }

    function clearAllData() {
        window.sessionStorage.clear()
    }
</script>
<button onclick="saveData()">点我保存一个数据</button>
<button onclick="getData()">点我读取一个数据</button>
<button onclick="deleteData()">点我删除一个数据</button>
<button onclick="clearAllData()">点我清空数据</button>
</body>
</html>